package com.itheima.dao;

import com.itheima.domain.Linkman;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

public class LinkmanDao extends HibernateDaoSupport{

    public void saveAdd(Linkman linkman) {
        this.getHibernateTemplate().save(linkman);
    }

    public List list() {
        List list = this.getHibernateTemplate().find("from com.itheima.domain.Linkman");
        return list;
    }

    public Linkman findOne(Linkman linkman) {
        Linkman l = this.getHibernateTemplate().get(Linkman.class, linkman.getLid());
        return l;
    }

    public void delete(Linkman l) {
        this.getHibernateTemplate().delete(l);
    }

    public List likeSerch(Linkman linkman) {
        List list = this.getHibernateTemplate().find("from com.itheima.domain.Linkman where lkmName like ?", "%" + linkman.getLkmName() + "%");
        return list;
    }

    public void saveEdit(Linkman linkman) {
        this.getHibernateTemplate().update(linkman);
    }
}
